import React from 'react';
import {withRouter} from 'react-router-dom';
 import {GoPageReplace} from '../../assets/js/utils'
import Css from './headNav.css';

class headNav extends React.Component{
    goBack(){
        // this.props.history.goBack()
        // goBack(this.props)
        if(this.props.location.pathname==='/asd/address/index'){
            this.props.history.replace(window.base.config.path+'balance/index')
        }else {
            //this.props.history.goBack()
            GoPageReplace(this.props)
        }
    }
    sumbit(){
        if (this.props.headBtn!==undefined){
            this.props.onClick()
        }
    }
    render(){
       return(
           <div className={Css['headNav']}>
               <div className={Css['headNavGobackIcn']} onClick={this.goBack.bind(this)}><i className={'goBackIcn fs50'} /></div>
               <div className={Css['headTitle']}>{this.props.title}</div>
               <div className={Css['headBtn']} onClick={this.sumbit.bind(this)}>{this.props.headBtn!==undefined?this.props.headBtn:'' }</div>
           </div>
       )
    }
}
export default withRouter(headNav)